<% /* $Id: problems.jsp 101 2010-12-26 21:25:55Z altdotua@gmail.com $ */ %>

<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@include file="header.jsp" %>

<%
	if (user == null)
	{
		response.sendRedirect(Linker.link("login.jsp?return=" + URLEncoder.encode(request.getRequestURI(), "UTF-8")));
		return;
	}
	HashMap<String, Object> map = new HashMap<String, Object>();
	map.put("contestId", contest.getId());
	if (!user.isAdmin())
	{
		map.put("active", true);
	}
	List<ContestProblemEntry> entries = ContestProblemsModel.getEntries(map);
	MonitorInterface monitorEntry = new BasicMonitor(contest.getId());
%>

<h2>Problem status summary</h2>

<table border="1" class="b1">
	<tr>
		<th class="b1">Short name</th>
		<th class="b1">Long name</th>
		<th class="b1">Status</th>
	</tr>
	
<%
	for (ContestProblemEntry problem: entries)
	{
		String color = "white";
		ProblemUserScoreEntry best = monitorEntry.getProblemUserScore(problem.getId(), user.getId());//stat.get(problem.getId());
		if (best == null)
			best = new ProblemUserScoreEntry();
		if (best.getRejectedCount() > 0 || best.getAcceptedCount() > 0 || best.getPendingCount() > 0)
		{
			if (best.getAccepted())
				color = "#ddffdd";
			else if (best.getPendingCount() > 0)
				color = "#ffffaa";
			else
				color = "#ffdddd";
		}
%>
		<tr bgcolor="<%= color %>">
			<td class="b1"><a href="<%= Linker.link("contests/problem.jsp?contest_id=" + contest.getId() + "&problem_id=" + problem.getId()) %>"><%= problem.getSid() %></a></td>
			<td class="b1"><a href="<%= Linker.link("contests/problem.jsp?contest_id=" + contest.getId() + "&problem_id=" + problem.getId()) %>"><%= problem.getName() %></a></td>
			<td class="b1">&nbsp;</td>
		</tr>
<%
	}
%>
</table>

<%
	String link = contest.getStatementsLink();
	if (null != link && link.length() > 0)
	{
%>
<h2><font color="red"><a href="<%= link %>">Скачати умови всіх задач</a></font></h2>
<%
	}
%>

<%@include file="footer.jsp"%>
